// api/game.js
const { request } = require('./core');

/**
 * 参与活动
 * @param {string} activit_type -	活动类型（签到：CHECK_IN、看广告：ADVERTISEMENT、分享：SHARE）
 * @returns {Promise}
 */
const applyActivities = (params = {}) => {
  return request({
    url: '/user/activities',
    method: 'GET',
    data: params,
    showLoading: true,
    loadingTitle: '提交中...',
  });
};
/**
 * 获取排行榜
 * @param {object} params - 查询参数
 * @returns {Promise}
 */
const getLeaderboard = (params = {}) => {
  return request({
    url: '/game/leaderboard',
    method: 'GET',
    data: params,
    showLoading: true,
  });
};

/**
 * 提交游戏分数
 * @param {number} score - 分数
 * @param {string} level - 难度等级
 * @returns {Promise}
 */
const submitScore = (score, level) => {
  return request({
    url: '/game/submit-score',
    method: 'POST',
    data: { score, level },
    showLoading: true,
    loadingTitle: '提交中...',
  });
};

/**
 * 获取游戏历史记录
 * @returns {Promise}
 */
const getGameHistory = () => {
  return request({
    url: '/game/history',
    method: 'GET',
    showLoading: true,
  });
};

// 导出游戏相关的所有接口
module.exports = {
  applyActivities,
  getLeaderboard,
  submitScore,
  getGameHistory,
};
